package plantshop.tests;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import plantshop.model.Location;
import plantshop.model.plants.*;

public class PlantTest {
	Plant test;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testPlant() {
		test = new Aster();
		assertFalse(test.isInvasive());
		assertEquals(75,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Aster",test.getName());
		
		test = new BurningBush();
		assertTrue(test.isInvasive());
		assertEquals(25,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Burning Bush",test.getName());
		
		test = new CommonMilkweed();
		assertFalse(test.isInvasive());
		assertEquals(75,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Common Milkweed",test.getName());
		
		test = new EasternRedCedar();
		assertFalse(test.isInvasive());
		assertEquals(75,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Eastern Red Cedar",test.getName());
		
		test = new EnglishIvy();
		assertTrue(test.isInvasive());
		assertEquals(25,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("English Ivy",test.getName());
		
		test = new JapaneseBarberry();
		assertTrue(test.isInvasive());
		assertEquals(25,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Japanese Barberry",test.getName());
		
		test = new NorwayMaple();
		assertTrue(test.isInvasive());
		assertEquals(25,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Norway Maple",test.getName());
		
		test = new SweetPepperbush();
		assertFalse(test.isInvasive());
		assertEquals(75,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("Sweet Pepperbush",test.getName());
		
		test = new WhiteOak();
		assertFalse(test.isInvasive());
		assertEquals(75,test.getAttractiveness());
		assertEquals(new Location(0,0),test.getLoc());
		assertEquals("White Oak",test.getName());
	}
	
	@Test
	public void testEquals(){
		test = new Aster();
		assertTrue(test.equals(new Aster()));
		assertFalse(test.equals(new Object()));
		assertFalse(test.equals(new WhiteOak()));
	}
	
	@Test
	public void testGetters(){
		test = new SweetPepperbush();
		assertFalse(test.getTakenOver());
		assertTrue(test.getAvailable());
		assertEquals(11,test.getValue());
		assertTrue(test.getTimePlanted()<=System.currentTimeMillis() && test.getTimePlanted() >= System.currentTimeMillis()-5000);
		assertFalse(test.isGrown());
		test.grow();
		assertTrue(test.isGrown());
		test.setTakenOver(true);
		assertTrue(test.getTakenOver());
	}
}
